package com.tian.controller.manage;

import com.tian.pojo.vo.OrderManageVO;
import com.tian.pojo.vo.UserManageVO;
import com.tian.service.manage.OrderManageService;
import com.tian.utils.JSONResult;
import com.tian.utils.PagedGridResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("manage")
public class OrderManageController {

    @Autowired
    private OrderManageService orderManageService;

    @GetMapping("/getOrderManage")
    public JSONResult getUserManage(
            @RequestParam Integer page,
            @RequestParam Integer pageSize){
        if (page==null){
            page=1;
        }
        if (pageSize==null){
            pageSize=10;
        }

        PagedGridResult gridResult = orderManageService.queryPagedOrderManage(page, pageSize);

        return JSONResult.ok(gridResult);

    }

    @GetMapping("/getOrderManageByOrderId")
    public JSONResult getOrderManageByOrderId(@RequestParam String orderId){
        if (StringUtils.isBlank(orderId)){
            JSONResult.errorMsg("null");
        }
        List<OrderManageVO> list = orderManageService.getOrderManageByOrderId(orderId);
        return JSONResult.ok(list);
    }
}
